<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件</title>
</head>
<body>
    <!-- 这种好像更加简单！！！ -->
    <script type="module">
        import { createApp } from '../../public/petite-vue-module.js'
      
        function Counter(props) {
          return {
            count: props.initialCount,
            inc() {
              this.count++
            },
            mounted() {
              console.log(`I'm mounted!`)
            }
          }
        }
      
        createApp({
          Counter
        }).mount()
      </script>
      
      <!-- 原理：复用的组件，是函数形式的！！！ -->
      <div v-scope="Counter({ initialCount: 1 })" @vue:mounted="mounted">
        <p>{{ count }}</p>
        <button @click="inc">increment</button>
      </div>
      
      <div v-scope="Counter({ initialCount: 2 })">
        <p>{{ count }}</p>
        <button @click="inc">increment</button>
      </div>
</body>
</html>